<template>
<div class="job">
        <div style="width: 100%;height: 60px">
          <div style=" margin-top: 20px; display: flex;padding: 0px 20px;border-bottom: 1px solid #0270c1;background-color: white;width: 95%;margin-left: 12px">
            <div>
              <img src="/src/assets/hy/zhiwei.png" height="30" width="30" style="margin: 5px 10px 0px 0px"/>
            </div>
            <div style="text-align: center;line-height: 40px;">岗位需求：</div>
          </div>

        </div>
        <div style="width: 98%;height: 80px;background:#FFFFFF;border: 1px solid #F1F1F1;margin: 0px 1% 0px">
          <div style="margin: 20px 10px;float: left">

          <el-input v-model="form2.postName" placeholder="岗位名称"  style="width:150px;margin-top: 5px"/>
          </div>
          <div style="margin: 20px 10px;float: left">

            <el-form-item style="width:150px;margin-top: 5px">
              <el-select placeholder="发布渠道" :value="d.sourceList" v-model="form2.sourceId" >
                <el-option v-for="a in d.sourceList"
                           :label="a.sourceName"
                           :key="a.sourceId"
                           :value="a.sourceId" />
              </el-select>
            </el-form-item>
          </div>
          <div style="margin: 20px 10px;float: left">

            <el-form-item style="width:150px;margin-top: 5px">
                <el-select placeholder="发布人" :value="d.jobNames" v-model="form2.empId" >
                  <el-option v-for="a in d.jobNames"
                             :label="a.empName"
                             :key="a.empId"
                             :value="a.empId" />
                </el-select>
            </el-form-item>
          </div>
          <div style="margin: 20px 10px;float: left">

            <el-form-item style="width:150px;margin-top: 5px">
              <el-select placeholder="发布状态" v-model="form2.jobStatus" >
                <el-option label="未发布" value="0" />
                <el-option label="已发布" value="1" />
                <el-option label="已关闭" value="3" />
              </el-select>
            </el-form-item>
          </div>
          <el-button @click="selectAlljob()" type="primary" style="margin: 25px 10px">搜索</el-button>
          <el-button  @click="qingkong()" plain>重置</el-button>
          <div class="aa" style="float: right;margin:25px 30px">
            <el-droodown-item>
              <router-link :to="{path:'/Recruitment/post/application'}" event="mouseover">
                <el-button type="primary">用工需求申请</el-button>
              </router-link>
            </el-droodown-item>
            <el-dropdown style="margin-left: 20px">
              <el-button type="primary">
                更多<el-icon class="el-icon--right"><arrow-down /></el-icon>
              </el-button>
              <template #dropdown>
                <el-dropdown-menu>
<!--                  <el-dropdown-item><span @click="dialogFormVisible = true">修改</span></el-dropdown-item>-->
                  <el-dropdown-item><span>删除</span></el-dropdown-item>
                  <el-dropdown-item><span>导入</span></el-dropdown-item>
                  <el-dropdown-item><span>导出</span></el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </div>
        <div style="float: left;margin: -5px 10px;">
          <div class="dangweirenshu">&nbsp;&nbsp;&nbsp;&nbsp;岗位人数<div style="font-size: 20px;line-height: 0px;">&nbsp;&nbsp;&nbsp;{{countemp}}</div></div>
          <div class="xuqiurenshu" >&nbsp;&nbsp;&nbsp;&nbsp;岗位需求人数<div style="font-size: 20px;line-height: 0px;">&nbsp;&nbsp;&nbsp;{{count}}</div></div>
        </div>
        <div style="width: 100%;height: 200px;margin-top: 100px">
          <el-table
              ref="multipleTableRef"
              :data="d.tableData"
              style="width: 98%;height: 346px;margin: auto"
              @selection-change="handleSelectionChange"
              stripe
              :header-cell-style="{background:'#f5f7fa'}"
          >
            <el-table-column align="center" type="selection" width="55" />
            <el-table-column align="center" label="岗位名称" >
              <template #default="scope">
                <el-button @click="postMag(scope.row)">
                  {{ scope.row.sysPost.postName }}
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" property="sysDept.deptName" label="申请部门"  />
            <el-table-column align="center" property="jobPlace" label="工作地点" show-overflow-tooltip />
            <el-table-column align="center" property="sysPost.postHadcount" label="编制人数" />
            <el-table-column align="center" property="jobNumber" label="需求人数" />
            <el-table-column align="center" property="jobDate" label="申请日期" />
            <el-table-column align="center" property="jobStatus" label="审批结果" >
              <template #default = "a">
                <div v-if="a.row.jobStatus==0">审批中</div>
                <div v-if="a.row.jobStatus==1">已通过</div>
                <div v-if="a.row.jobStatus==2">已拒绝</div>
              </template>
            </el-table-column>
            <el-table-column align="center" label="发布状态">
              <template #default ="s">
                <div v-if="s.row.jobPoststatus==0" style="background:rgb(234,242,251);color:#446af3;height:30px;width:60%;margin:0 20% 0;font-size: 13px;line-height: 30px">
                  未发布
                </div>
                <div v-if="s.row.jobPoststatus==1" style="background:rgb(234,242,251);color:#479d5c;height:30px;width:60%;margin:0 20% 0;font-size: 13px;line-height: 30px">
                  已发布
                </div>
                <div v-if="s.row.jobPoststatus==2" style="background:rgb(234,242,251);color:#f34444;height:30px;width:60%;margin:0 20% 0;font-size: 13px;line-height: 30px">
                  已撤回
                </div>
                <div v-if="s.row.jobPoststatus==3"  style="background:rgb(234,242,251);color:#be00fc;height:30px;width:60%;margin:0 20% 0;font-size: 13px;line-height: 30px">
                  已重新发布
                </div>
                <div v-if="s.row.jobPoststatus==4" style="background:rgb(234,242,251);color:#000000;height:30px;width:60%;margin:0 20% 0;font-size: 13px;line-height: 30px">
                  已关闭
                </div>
              </template>
            </el-table-column>
            <el-table-column align="center" property="name" label="操作">
              <template #default ="s">
                <el-button v-if="s.row.jobPoststatus==0" @click="fabuanniu(s.row)" type="primary" plain>
                  发布
                </el-button>
                <el-button v-if="s.row.jobPoststatus==1" @click="fabuzt(s.row)" type="danger" plain>
                 撤回
                </el-button>
                <el-button v-if="s.row.jobPoststatus==2" @click="fabuanniu(s.row)" type="success" plain>
                 重新发布
                </el-button>
                <el-button v-if="s.row.jobPoststatus==3" text @click="open(s.row)">关闭</el-button>
                <div v-if="s.row.jobPoststatus==4" style="background:rgb(217,246,229);color:#479d5c;height:30px;width:60px;margin:0 30% 0;font-size: 12px;line-height: 30px;border: 1px solid #479D5C;border-radius: 4px" >
                  已关闭
                </div>
              </template>
            </el-table-column>
          </el-table>
          <div>
            <el-row justify="center">
              <el-col>
                <el-pagination
                    v-model:currentPage="d.pageNo"
                    v-model:page-size="d.pageSize"
                    :page-sizes="[5,10, 20, 30, 40]"
                    :small="small"
                    :disabled="disabled"
                    :background="background"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="d.total"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                />
              </el-col>
            </el-row>
          </div>
        </div>
  <el-drawer v-model="drawer" title="I am the title" :with-header="false" size="60%">
    <span>岗位需求信息</span>
    <el-button v-if="job.jobPoststatus == 0 || job.jobPoststatus == 2" type="primary" style="margin-left: 640px" @click="putJob()">编辑</el-button>
      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
        <el-tab-pane label="基本信息" name="first">
          <el-form  label-width="120px" :model="jobren" disabled>
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">申请人信息</p>
            <div class="gangweixx">
              <div  style="margin-top: 30px;">
                <el-form-item label="申请人" style="width: 400px;float: left">
                  <el-input v-model="jobren.shenqingempName" />
                </el-form-item>

                <el-form-item label="申请部门" style="width: 400px">
                  <el-input v-model="jobren.shenqingdeptName"/>
                </el-form-item>
                <el-form-item label="申请人岗位" style="width: 400px;float: left">
                  <el-input v-model="jobren.shenqingpostName" />
                </el-form-item>
                <el-form-item label="申请日期" style="width: 400px">
                  <el-input v-model="job.jobDate"/>
                </el-form-item>
                <el-form-item label="申请发布渠道" style="width: 400px">
                  <el-input v-model="job.sourceName" />
                </el-form-item>
              </div>
            </div>
          </el-form>
          <el-form  label-width="120px" :model="job"  v-if="job.jobPoststatus == 0 || job.jobPoststatus == 2 ">
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">岗位信息</p>
            <div class="gangweixx">
              <div  style="margin-top: 30px;">
<!--                <el-form-item label="部门名称" style="width: 400px;float: left">-->
<!--                  <el-input v-model="job.deptName" />-->
<!--                </el-form-item>-->
                <el-form-item label="部门名称" style="width: 400px;float: left">
                  <el-select  filterable="true"
                              @mouseout="onClick"
                              allow-create :value="d.dept" v-model="job.deptId" placeholder="请选择" style="width: 300px;">
                    <el-option v-for="c in d.dept"
                               :label="c.deptName"
                               :key="c.deptId"
                               :value="c.deptId" />
                  </el-select>
                </el-form-item>
<!--                <el-form-item label="岗位名称" style="width: 400px">-->
<!--                  <el-input v-model="job.postName"/>-->
<!--                </el-form-item>-->
                <el-form-item label="补增岗位名称" style="width: 400px">
                <el-select  filterable="true"
                            allow-create :value="d.postss" v-model="job.postId" placeholder="请选择" style="width: 300px;">
                  <el-option v-for="c in d.postss"
                             :label="c.postName"
                             :key="c.postId"
                             :value="c.postId" />
                </el-select>
                </el-form-item>
                <el-form-item label="需求人数" style="width: 400px;float: left">
                  <el-input  v-model="job.jobNumber"/>
                </el-form-item>
                <el-form-item label="工作地点" style="width: 400px">
                  <el-input v-model="job.jobPlace"/>
                </el-form-item>
                <el-form-item label="岗位职责">
                  <el-input  :rows="4" type="textarea" style="width: 89.5%" v-model="job.jobPosition" />
                </el-form-item>
            </div>
          </div>
          </el-form>
          <el-form  label-width="120px" :model="job" disabled v-if="job.jobPoststatus == 1 || job.jobPoststatus == 3 || job.jobPoststatus == 4">
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">岗位信息</p>
            <div class="gangweixx">
              <div  style="margin-top: 30px;">
                <!--                <el-form-item label="部门名称" style="width: 400px;float: left">-->
                <!--                  <el-input v-model="job.deptName" />-->
                <!--                </el-form-item>-->
                <el-form-item label="部门名称" style="width: 400px;float: left">
                  <el-select  filterable="true"
                              @mouseout="onClick"
                              allow-create :value="d.dept" v-model="job.deptId" placeholder="请选择" style="width: 300px;">
                    <el-option v-for="c in d.dept"
                               :label="c.deptName"
                               :key="c.deptId"
                               :value="c.deptId" />
                  </el-select>
                </el-form-item>
                <!--                <el-form-item label="岗位名称" style="width: 400px">-->
                <!--                  <el-input v-model="job.postName"/>-->
                <!--                </el-form-item>-->
                <el-form-item label="补增岗位名称" style="width: 400px">
                  <el-select  filterable="true"
                              allow-create :value="d.postss" v-model="job.postId" placeholder="请选择" style="width: 300px;">
                    <el-option v-for="c in d.postss"
                               :label="c.postName"
                               :key="c.postId"
                               :value="c.postId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="需求人数" style="width: 400px;float: left">
                  <el-input  v-model="job.jobNumber"/>
                </el-form-item>
                <el-form-item label="工作地点" style="width: 400px">
                  <el-input v-model="job.jobPlace"/>
                </el-form-item>
                <el-form-item label="岗位职责">
                  <el-input  :rows="4" type="textarea" style="width: 89.5%" v-model="job.jobPosition" />
                </el-form-item>
              </div>
            </div>
          </el-form>
          <el-form  label-width="120px"  :model="job2" disabled>
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">岗位发布信息</p>
            <div class="gangweixx">
              <div style="margin-top: 30px;">
                <el-form-item label="发布人" style="width: 400px;float: left">
                  <el-input v-model="job2.empName2" />
                </el-form-item>
                <el-form-item label="发布日期" style="width: 400px">
                  <el-input v-model="job2.recordTime" />
                </el-form-item>
                <el-form-item label="发布渠道" style="width: 400px;float: left">
                  <el-input v-model="job2.recordSourceName"  />

                </el-form-item>
                <el-form-item label="发布状态" style="width: 400px">
                  <el-input v-if="job.jobPoststatus == 0 " value="未发布"/>
                  <el-input v-if="job.jobPoststatus == 1 " value="已发布"/>
                  <el-input v-if="job.jobPoststatus == 2 " value="已撤回发布"/>
                  <el-input v-if="job.jobPoststatus == 3 " value="已重新发布"/>
                  <el-input v-if="job.jobPoststatus == 4 " value="已关闭"/>
                </el-form-item>
              </div>
            </div>
          </el-form>
          <el-form  label-width="120px" v-if="job.jobPoststatus == 0 || job.jobPoststatus == 2">
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">招聘基本需求</p>
            <div class="gangweixx">
              <div  style="margin-top: 30px;">
<!--                <el-form-item label="学历">-->
<!--                  <el-input v-model="job.jobEducation" />-->
<!--                </el-form-item>-->
                <el-form-item label="学历" prop="region" style="float: left;width: 400px;">
                  <el-select :value="d.educationList" v-model="job.educationId" placeholder="请选择" style="width: 400px;" >
                    <el-option v-for="c in d.educationList"
                               :label="c.educationName"
                               :key="c.educationId"
                               :value="c.educationId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="工作经验" prop="region">
                  <el-select :value="d.experienceList" v-model="job.experienceId" placeholder="请选择" style="width: 280px;">
                    <el-option v-for="d in d.experienceList"
                               :label="d.experienceName"
                               :key="d.experienceId"
                               :value="d.experienceId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="年龄下限" style="width: 400px;float: left">
                  <el-input  v-model="job.jobOverage"/>
                </el-form-item>
                <el-form-item label="年龄上限" style="width: 400px">
                  <el-input  v-model="job.jobLimitage"/>
                </el-form-item>
                <el-form-item label="薪资下限" style="width: 400px;float: left">
                  <el-input  v-model="job.jobSalaryfloor"/>
                </el-form-item>
                <el-form-item label="薪资上限" style="width: 400px">
                  <el-input v-model="job.jobSalarycap" />
                </el-form-item>
                <el-form-item label="专业" style="width: 400px;">
                  <el-input  v-model="job.jobTechnology"/>
                </el-form-item>
                <el-form-item label="其他">
                  <el-input  :rows="4" type="textarea" style="width: 89.5%" v-model="job.jobElse"/>
                </el-form-item>
              </div>
            </div>
        </el-form>
          <el-form  label-width="120px" disabled v-if="job.jobPoststatus == 1 || job.jobPoststatus == 3 || job.jobPoststatus == 4">
            <p style="height: 30px;font-size: 13px;margin-bottom: 0px;line-height: 40px;">招聘基本需求</p>
            <div class="gangweixx">
              <div  style="margin-top: 30px;">
                <!--                <el-form-item label="学历">-->
                <!--                  <el-input v-model="job.jobEducation" />-->
                <!--                </el-form-item>-->
                <el-form-item label="学历" prop="region" style="float: left;width: 400px;">
                  <el-select :value="d.educationList" v-model="job.educationId" placeholder="请选择" style="width: 400px;" >
                    <el-option v-for="c in d.educationList"
                               :label="c.educationName"
                               :key="c.educationId"
                               :value="c.educationId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="工作经验" prop="region">
                  <el-select :value="d.experienceList" v-model="job.experienceId" placeholder="请选择" style="width: 280px;">
                    <el-option v-for="d in d.experienceList"
                               :label="d.experienceName"
                               :key="d.experienceId"
                               :value="d.experienceId" />
                  </el-select>
                </el-form-item>
                <el-form-item label="年龄下限" style="width: 400px;float: left">
                  <el-input  v-model="job.jobOverage"/>
                </el-form-item>
                <el-form-item label="年龄上限" style="width: 400px">
                  <el-input  v-model="job.jobLimitage"/>
                </el-form-item>
                <el-form-item label="薪资下限" style="width: 400px;float: left">
                  <el-input  v-model="job.jobSalaryfloor"/>
                </el-form-item>
                <el-form-item label="薪资上限" style="width: 400px">
                  <el-input v-model="job.jobSalarycap" />
                </el-form-item>
                <el-form-item label="专业" style="width: 400px;">
                  <el-input  v-model="job.jobTechnology"/>
                </el-form-item>
                <el-form-item label="其他">
                  <el-input  :rows="4" type="textarea" style="width: 89.5%" v-model="job.jobElse"/>
                </el-form-item>
              </div>
            </div>
          </el-form>
      </el-tab-pane>
<!--        <el-tab-pane label="简历推送" name="second">简历推送</el-tab-pane>-->
<!--        <el-tab-pane label="面试情况" name="third">面试情况</el-tab-pane>-->
<!--        <el-tab-pane label="入职情况" name="fourth">入职情况</el-tab-pane>-->
    </el-tabs>
  </el-drawer>

</div>

</template>

<script lang="ts" setup>
import {
  Search,
} from '@element-plus/icons-vue'
import type { TabsPaneContext } from 'element-plus'
import {onBeforeMount, reactive, ref, toRefs} from "vue";
import axios from "axios";
import {useRouter} from "vue-router";
import {ElMessage, ElMessageBox} from "element-plus";
//进入发布页面
const router=useRouter();
const fabuanniu = (row)=>{
  router.push({path:"/Recruitment/resume/jobfabu",query:{id:row.jobId}})
}

const d = reactive({
  //table当前展示的数据
  list:null,
  //总记录
  total:0,
  //页码
  pageNo:1,
  //页大小
  pageSize:10,
  //数据
  tableData:[],
  //人才渠道数据
  sourceList:[],
  //发布人数据
  jobNames:[],
  qq:[],
  //学历数据
  educationList:[],
  //工作经验数据
  experienceList:[],
  //部门数据
  dept:[],
  //职位数据
  postList:[],
  //职位下拉框数据
  postss:[],

})

//获取当前时间
import moment from 'moment';
import {useStore} from "vuex";
let riqi = moment(new Date()).format("YYYY-MM-DD hh:mm:ss")
let aaaaaaa = ref()
// aaaaaaa.value = job2.recordSourceName;
//当前登录者的信息
const store=useStore();
const jobRecord = reactive({
  jobId:'',
  //发布时间
  recordTime:'',
  empId:store.state.user.sysEmployee.empId,
  recordSourceName:'',
})
//新增一条岗位需求记录
let add=ref();
const addJobRecord=()=>{
  console.log(jobRecord)
  axios.post("personnelOa/jobRecord/addchehui",jobRecord)
      .then((res)=>{
        add.value = res.data.data
        if(add.value < 0 ){
          ElMessage({
            type: 'success',
            message: '发布失败',
          })
        }
      })
}
//修改撤回状态
let fa = ref();
const fabuzt=(row)=>{
  jobRecord.jobId= row.jobId
  console.log(aaaaaaa.value)
  axios.post("personnelOa/job/upstatus2/"+row.jobId)
      .then((res)=>{
        fa.value = res.data.data
        addJobRecord();
        date();
        source();
        countJob();
        countEmp();
        jobName();
        experience();
        education();
        dept();
        ElMessage({
          type: 'success',
          message: '撤回成功',
        })
      })
}
//修改岗位需求数据
let put = ref();
const putJob=()=>{
  console.log(job)
  axios.put("personnelOa/jib/uptJob",job)
      .then((res)=>{
      put.value = res.data.data
        if(put.value > 0 ){
          ElMessage({
            type: 'success',
            message: '修改成功',
          })
          date();
          drawer.value = false
        }else {
          ElMessage({
            type: 'success',
            message: '修改失败',
          })
        }
  })
}
const open = (row) => {
  ElMessageBox.confirm(
      '确定关闭岗位发布吗?',
      '发布确认框',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }
  )
      .then(() => {
        fabuzt4(row);
        ElMessage({
          type: 'success',
          message: '关闭成功',
        })
      })
      .catch(() => {
        ElMessage({
          type: 'info',
          message: '关闭失败',
        })
      })
}
//新增一条岗位需求关闭记录
let add4=ref();
const addJobRecord4=()=>{
  console.log(jobRecord)
  axios.post("personnelOa/jobRecord/add4",jobRecord)
      .then((res)=>{
        add4.value = res.data.data
        if(add4.value < 0 ){
          ElMessage({
            type: 'success',
            message: '发布失败',
          })
        }
      })
}
//修改关闭状态
let fa4 = ref();
const fabuzt4=(row)=>{
  jobRecord.jobId= row.jobId
  axios.post("personnelOa/job/upstatus4/"+row.jobId)
      .then((res)=>{
        fa4.value = res.data.data
        addJobRecord4();
        date();
        source();
        countJob();
        countEmp();
        jobName();
        experience();
        education();
        dept();
      })
}
//鼠标点击的事件。
const onClick=(e)=> {
  posts();
}
//根据选中的部门查询职位
const posts = ()=>{
  console.log(job.deptId)
  axios.post("personnelOa/dept/deptpost/"+job.deptId).then((res)=>{
    d.postList = res.data.data
    d.postss = d.postList[0].posts
  })
}
//查询全部部门
const dept=()=>{
  axios.post("personnelOa/dept/deptss")
      .then((res)=>{
        d.dept =res.data.data;
      })
      .catch()
}
//查询出所有的工作经验
const experience =()=>{
  axios.post("personnelOa/Experience/selectlist")
      .then((res)=>{
        d.experienceList = res.data.data
      })
}
//查询出所有学历
const education =()=>{
  axios.post("personnelOa/Education/selectlist")
      .then((res)=>{
        d.educationList = res.data.data
      })
}

//发布人下拉框数据
const jobName=()=>{
  axios.post("personnelOa/SysEmployee/jobName")
      .then((res)=>{
        d.jobNames = res.data.data
        console.log(d.jobNames)
      })
}
const job = reactive({
  jobId:'',
  jobTitle:'',
  deptName:'',
  postName:'',
  empName:'',
  jobDate:'',
  jobNumber:'',
  jobReason:'',
  sourceName:'',
  jobPosition:'',
  jobEducation:'',
  jobExperience:'',
  jobPlace:'',
  jobLimitage:'',
  jobOverage:'',
  jobSalarycap:'',
  jobSalaryfloor:'',
  jobTechnology:'',
  jobPubdate:'',
  jobPoststatus:'',
  jobElse:'',
  //发布时间
  recordTime:'',
  //发布人
  empName2:'',
  //发布人部门
  postName2:'',
  empId:'',
  //申请部门
  deptId:'',
  //申请岗位
  postId:'',
  //学历
  educationId:'',
  //工作经验
  experienceId:''
})
const drawer = ref(false)
const postMag = (row) =>{
  //岗位需求id
  job.jobId = row.jobId
  //岗位需求标题
  job.jobTitle = row.jobTitle
  job.deptName = row.sysDept.deptName;
  job.postName = row.sysPost.postName;
  job.deptId = row.sysDept.deptId;
  job.postId = row.sysPost.postId;
  //申请时间
  job.jobDate = row.jobDate
  //需求人数
  job.jobNumber = row.jobNumber
  //需求理由
  job.jobReason = row.jobReason
  //用工来源
  job.sourceName = row.source.sourceName
  //岗位职责
  job.jobPosition = row.jobPosition
  //学历
  job.jobEducation = row.education.educationName
  job.educationId = row.education.educationId
  //工作经验
  job.jobExperience = row.experience.experienceName
  job.experienceId = row.experience.experienceId
  //工作地点
  job.jobPlace = row.jobPlace
  //年龄上限
  job.jobLimitage = row.jobLimitage
  //年龄下限
  job.jobOverage = row.jobOverage
  //薪资上限
  job.jobSalarycap = row.jobSalarycap
  //薪资下限
  job.jobSalaryfloor = row.jobSalaryfloor
  //技术
  job.jobTechnology = row.jobTechnology
  //发布状态
  job.jobPoststatus = row.jobPoststatus
  //其他
  job.jobElse = row.jobElse
  // //发布时间
  // job.recordTime = row.recordTime
  // //发布人姓名
  // job.empName2 = d.qq.jobRecord.employee.empName
  // //发布人部门
  // job.postName2 = row.employee.dept.deptName;
  drawer.value = true
  console.log(row)
  xiangqi();
  shenqinren();
}
const job2 = reactive({
  recordResult:'',
  empName2:'',
  recordTime:'',
  recordSourceName:'',
})

//查询需求数据记录
const xiangqi=()=>{
  axios.post("personnelOa/job/fabujilu/"+job.jobId)
      .then((res)=>{
        console.log("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")
        let q = res.data.data;
        console.log(q[0])
        job2.empName2 = q[0].jobRecord.employee.empName;
        job2.recordTime = q[0].jobRecord.recordTime;
        job2.recordSourceName = q[0].jobRecord.recordSourceName;
        job2.recordResult = q[0].jobRecord.recordResult;
         console.log(job2.recordResult)
      })
}
const jobren = reactive({
  shenqingempName:'',
  shenqingpostName:'',
  shenqingdeptName:'',
})
//查询需求数据申请人
const shenqinren=()=>{
  axios.post("personnelOa/job/shrnqingren/"+job.jobId)
      .then((res)=>{
        console.log("qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq")
        let a = res.data.data;
        console.log(a)
        jobren.shenqingempName = a.employee.empName
        jobren.shenqingdeptName =a.employee.dept.deptName
        jobren.shenqingpostName =a.employee.employeePost.post.postName

      })
}
//查询出所有的岗位需求数据
const date=()=>{
  axios.post("personnelOa/job/selectjob")
      .then((res)=>{
        d.tableData =res.data.data;
        console.log(res.data.data)
        ALltableData.value = d.tableData;//放入表格
        d.total = res.data.data.length;//获得它的长度
        // getTabelData();//调用方法
      })
      .catch()
}
const ALltableData=ref([])
const getTabelData=()=>{//分页，这里没必要管一样就行
  let data =JSON.parse(JSON.stringify(ALltableData.value));//把数据转为JSON格式
  let shu = data.splice(
      (d.pageNo - 1) * d.pageSize,
      d.pageSize
  )
  d.tableData = shu ;
}

const handleSizeChange = (val: number) => {//分页，这里没必要管一样就行
  d.pageSize = val ;
  d.pageNo = 1;
  getTabelData();
}

const handleCurrentChange = (val: number) => {//分页，这里没必要管一样就行
  console.log("翻页，当前为第几页", val)
  d.pageNo = val;
  getTabelData();
}
//一进页面就调用
onBeforeMount(()=>{
  date();
  source();
  countJob();
  countEmp();
  jobName();
  experience();
  education();
  dept();
})

//表单数据模型
let form2 = reactive({
  sourceId:'',
  postName:'',
  empId:'',
  jobStatus:'',

})
//搜索条件查询
const selectAlljob=()=>{
  console.log(form2)
  axios.post("personnelOa/job/selectAlljob",form2)
      .then((res)=>{
        d.tableData =res.data.data;
        ALltableData.value = d.tableData;//放入表格
        d.total = res.data.data.length;//获得它的长度
        console.log(ALltableData)
  })
}
const qingkong=()=>{
  form2.empId = '',
      form2.postName = '',
      form2.sourceId = '',
      form2.jobStatus = '',
  date();
}
const source =()=>{
  axios.post("personnelOa/source/selectlist")
      .then((res)=>{
      d.sourceList = res.data.data
        console.log(d.sourceList)
  })
}

const activeName = ref('first')
const handleClick = (tab: TabsPaneContext, event: Event) => {
  console.log(tab, event)
}
//查询需求岗位人数
const count=ref();
const countJob=()=>{
  axios.post("personnelOa/job/countJob")
      .then((res)=>{
        count.value = res.data.data
      })
      .catch()
}
//查询在岗位人数
const countemp=ref();
const countEmp=()=>{
  axios.post("personnelOa/SysEmployee/countEmp")
      .then((res)=>{
        countemp.value = res.data.data
      })
      .catch()
}
</script>

<style scoped>
.job{
  width: 100%;
  height: 100%;
  background: #F1F1F1;
  overflow: hidden;
}
.dangweirenshu{
  width: 630px;
  height: 80px;
  background:#FFFFFF;
  float: left;
  margin-left: 3px;
  font-size: 15px;
  line-height: 55px;

}
.xuqiurenshu{
  width: 630px;
  height: 80px;
  background:#FFFFFF;
  float: left;
  margin-left: 11px;
  font-size: 15px;
  line-height: 55px;
}
.demo-tabs > .el-tabs__content {
  padding: 32px;
  color: #6b778c;
  font-size: 32px;
  font-weight: 600;
}
.gangweixx{
  border-top: 2px solid #E4E7ED;
  /*margin-top: 50px;*/
}
.aa a{
  text-decoration: none;
}
</style>